package lcy.homework01;

import java.util.Objects;

/**
 * @ClassName: Circle
 * @Description:
 * @author: 李春洋
 * @date: 2024/3/30 16:25
 * @Blog: https://
 */
public class Circle extends Shape {
    Point center;
    double radius;

    Circle(Point center, double radius) {
        this.center = center;
        this.radius = radius;
    }

    void zoom(double d) {
        radius *= d;
    }

    @Override
    double calculatePerimeter() {
        return 2 * Math.PI * radius;
    }

    @Override
    double calculateArea() {
        return Math.PI * radius * radius;
    }

    @Override
    void move(Point p) {
        center.x += p.x;
        center.y += p.y;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) return true;
        if (!(obj instanceof Circle)) return false;
        Circle other = (Circle) obj;
        return center.equals(other.center) && radius == other.radius;
    }

    @Override
    public int hashCode() {
        return Objects.hash(center, radius);
    }

    @Override
    public String toString() {
        return "圆 [中点 =" + center + ", 半径=" + radius + "]";
    }
}
